From 26d3fc311b98c9baf2131609ff724d3e196c77f4 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 20 Mar 2013 21:47:12 -0400 Subject: [PATCH] wayland: Keep hotspot when changing cursors We need to pass the delta between the old and new hotspot when attaching the new cursor surface, to keep the hotspot at the same position. We can't deal with this in the compositor, since the set_cursor call already overwrites the old hotspot, so the information is lost by the time the attach happens. Unfortunately, we can't query the initial hotspot from the compositor, so the first cursor change will make the hotspot jump. https://bugzilla.gnome.org/show_bug.cgi?id=695512 --- gdk/wayland/gdkdevice-wayland.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index e7776c86c8..24176e98f9 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -76,6 +76,7 @@ struct _GdkWaylandDeviceData GdkWaylandSelectionOffer *selection_offer_out; struct wl_surface *pointer_surface; + int hotspot_x, hotspot_y; }; struct _GdkWaylandDevice @@ -172,10 +173,13 @@ gdk_wayland_device_set_window_cursor (GdkDevice *device, _gdk_wayland_display_get_serial (wayland_display), wd->pointer_surface, x, y); - wl_surface_attach (wd->pointer_surface, buffer, 0, 0); + wl_surface_attach (wd->pointer_surface, buffer, wd->hotspot_x - x, wd->hotspot_y - y); wl_surface_damage (wd->pointer_surface, 0, 0, w, h); wl_surface_commit(wd->pointer_surface); + wd->hotspot_x = x; + wd->hotspot_y = y; + g_object_unref (cursor); } -- 2.30.2